<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<style>
    .minyuan_red{padding: 4px;background-color: red;border-radius: 50%;font-size: 0!important;margin-right: 6px;position: relative;top: -4px;}
    .minyuan_lv{padding: 4px;background-color: #19BE6B;border-radius: 50%;font-size: 0!important;margin-right: 6px;position: relative;top: -4px;}
</style>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">人员姓名</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">劳动合同编号</label>
                        <div class="layui-input-block">
                            <input type="text" name="number" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">合同期限类型</label>
                        <div class="layui-input-block">
                            <div id="tongtype" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">期限起</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="xiandt" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">期限止</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="xianzhidt" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">试用期起</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="shidt" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">试用期止</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="shizhidt" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">合同状态</label>
                        <div class="layui-input-block">
                            <select id="state" name="state" lay-filter="state"></select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">合同性质</label>
                        <div class="layui-input-block">
                            <select id="nature" name="nature" lay-filter="nature"></select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">签约日期</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="qiandt" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                                <div id="search_open" onclick="toggle_search()">
                                    <i class="layui-icon layui-icon-down"></i>展开
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
        <a href="javascript:;" class="bar_opt" onclick="auth_but_func_show('查看','{{d.LAY_TABLE_INDEX}}')">查看</a>
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>




    var currButAuth, currTabData;
    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;

        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        setSouTableExport('劳动合同');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_archive_tong_list),where: {}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text
            ,parseData: function (res) {
                currButAuth = res.data.butauth;
                tableButShow(currButAuth);

                xmselect_dan('acctype', res.data.acctype, res.data.is_acctype, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })
                xmselect_dan('tongtype', res.data.tongtype, res.data.is_tongtype, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })

                var nature_str = '<option value="">请选择</option>';
                var nature = res.data.nature;
                for (var key in nature){
                    if(res.data.is_nature == nature[key]){
                        nature_str += '<option value="'+nature[key]+'" selected>'+nature[key]+'</option>';
                    }else {
                        nature_str += '<option value="'+nature[key]+'">'+nature[key]+'</option>';
                    }

                }
                $("#nature").html(nature_str);


                var state_str = '<option value="">请选择</option>';
                var state = res.data.state;
                for (var key in state){
                    if(res.data.is_state == state[key]){
                        state_str += '<option value="'+state[key]+'" selected>'+state[key]+'</option>';
                    }else {
                        state_str += '<option value="'+state[key]+'">'+state[key]+'</option>';
                    }

                }
                $("#state").html(state_str);

                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left'}
                ,{type:'numbers',title:'序号',fixed:'left'}
                ,{field: 'name', title: '人员姓名'}
                ,{field: 'number', title: '劳动合同编号'}
                ,{field: 'tongtype', title: '合同期限类型'}
                ,{field: 'xiandt', title: '期限起'}
                ,{field: 'xianzhidt', title: '期限止'}
                ,{field: 'shidt', title: '试用期起'}
                ,{field: 'shizhidt', title: '试用期止'}
                ,{field: 'gongfee', title: '试用工资(元/月)'}
                ,{field: 'zhuanfee', title: '转正工资(元/月)'}
                ,{field: 'state', title: '合同状态'}
                ,{field: 'nature', title: '合同性质'}
                ,{field: 'zhongdt', title: '提前终止日期'}
                ,{field: 'qiandt', title: '签约日期'}
                ,{fixed: 'right', title:'操作', toolbar: '#test-dropdown-toolbar-barDemo',align:'center',width:200}
            ]]
            , done: function (res) {
                soulTable.render(this);

                currTabData = res.data;
                $.each(currTabData, function(index,item){
                    var chk = $('tr[data-index=' + item.LAY_TABLE_INDEX + '] .tab-list-authbut');
                    for (var key in currButAuth) {
                        if(currButAuth[key].pagetype === 0 || currButAuth[key].pagetype === 1){
                            chk.append(' <a ' +
                                'href="javascript:;" ' +
                                'class="bar_opt layui-hide" ' +
                                'lay-event="search" ' +
                                'data-butname="'+currButAuth[key].butname+'" ' +
                                'data-title="'+currButAuth[key].title+'" ' +
                                'onclick="auth_but_func_'+currButAuth[key].butname+'(\''+currButAuth[key].title+'\', '+index+')"' +
                                '>'+currButAuth[key].title+'' +
                                '</a>');
                        }
                    }
                });
                show_tab_but(currTabData);
            }
        });


        listTableSearch(form, table);
    });


    function auth_but_func_show(buttitle, index){
        var trData = currTabData[index];
        openPage('show.php?id='+trData.id);
    }
    function auth_but_func_add(){
        openPageEdit('add.php?close=1');
    }
    function auth_but_func_add_flow(){
        openPageEdit('flow_add.php?close=1');
    }
    function auth_but_func_edit(buttitle, index){
        var trData = currTabData[index];
        openPageEdit('edit.php?close=1&id='+trData.id);
    }
    function auth_but_func_delete(buttitle, index){
        var trData = currTabData[index];
        data_delete(ask_archive_tong_del, {id:trData.id});
    }


</script>
</body>
</html>
